<template>
    <div>
        <el-table :data="tableData"
                  @selection-change="handleSelectionChange" stripe border style="width:100%">
            <el-table-column type="selection" min-width="2%"
                             align="center" v-if="!isView"></el-table-column>
            <el-table-column label="产品名称" prop="name" min-width="20%"
                             align="center"></el-table-column>
            <el-table-column label="材质" prop="material" min-width="20%"
                             align="center"></el-table-column>
            <el-table-column label="加工方式" prop="method" min-width="10%"
                             align="center"></el-table-column>
            <el-table-column label="表面处理" prop="surface" min-width="10%"
                             align="center"></el-table-column>
            <el-table-column label="数量" prop="numDescr" min-width="10%"
                             align="center"></el-table-column>

            <el-table-column label="单价" prop="price" header-align="center" min-width="10%"
                             align="right"></el-table-column>

            <el-table-column label="操作" align="center" min-width="18%" >
                <template slot-scope="scope">
                    <el-button type="edit" size="small" icon="el-icon-edit" v-if="!isView"
                               @click="showEditQuotItem(scope.row)" >编辑</el-button>
                    <el-button type="primary" size="small" icon="el-icon-view"
                               @click="viewQuotItem(scope.row)">查看</el-button>
                </template>
            </el-table-column>
        </el-table>
    </div>
</template>

<script>
import { mapState } from 'vuex';

export default {
    name: "QuotItemList",
    props: ['tableData'],
    data() {
        return {

        }
    },

    computed: {
        ...mapState({
            isView: state => state.quot.isView
        }),
    },

    methods: {
        handleSelectionChange(val) {
            console.log("选中的元素: ", val); // val 中是所有选中的元素的值
            this.$store.commit("quot/Set_Selected_Item", val);

        },

        showEditQuotItem(quotItem) {
            this.$store.commit("quot/Show_Edit_Quot_Item", quotItem)
        },

        viewQuotItem(quotItem){
            console.log("111")
            this.$store.commit("quot/showViewQuotItem", quotItem)
        }

    }
}
</script>

